This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
#replace missing value with 0
data <- read.csv("Ames_data.csv")
testIDs <- read.table("project1_testIDs.dat")
j <- 2
train <- data[-testIDs[,j], ]
test <- data[testIDs[,j], ]
test.y <- test[, c(1, 83)]
test <- test[, -83]
write.csv(train,"train.csv",row.names=FALSE)
write.csv(test, "test.csv",row.names=FALSE)
write.csv(test.y,"test_y.csv",row.names=FALSE)
train.y = log10(train$Sale_Price)
train$PID=NULL
train$Sale_Price=NULL
train
train.y
[1] 5.332438 5.235528 5.387390 5.278525 5.282169 5.373831 5.276462 5.267172 5.256237 5.234264 5.730782 5.214844 5.322219 5.278754 5.334454
[16] 5.173186 5.175802 5.152288 5.100371 5.060698 5.264818 4.982271 5.105510 5.175802 5.079181 5.164353 5.485721 5.439333 5.413300 5.330414
[31] 5.786508 5.350248 5.698970 5.505150 5.311754 5.244277 5.204120 5.283301 5.265996 5.335458 5.267378 5.255273 5.347330 5.522663 5.344392
[46] 5.612784 5.345374 5.310693 5.406370 5.433770 5.257679 5.096910 5.288920 5.181844 5.232996 4.829304 5.170262 5.086360 5.123852 5.227887
[61] 5.278754 5.559308 5.454845 5.414973 5.278754 5.190332 5.178977 5.174641 5.181844 5.346353 5.247973 5.190332 5.167642 5.427999 5.190332
[76] 5.313867 5.115611 5.361728 5.339451 5.232996 5.153052 5.110421 5.201397 5.252610 5.256477 5.152670 5.295787 5.236789 5.066326 4.883661
[91] 5.107210 5.184691 5.120574 5.250420 5.278754 5.330414 5.133539 5.218798 5.161368 5.170262 5.152288 5.224015 5.035582 5.202761 5.033424
[106] 5.088136 5.075547 5.037426 5.031408 5.110590 5.209515 5.383815 5.187521 5.220108 5.129690 5.204120 5.170262 5.190332 4.984527 5.039414
[121] 5.060698 5.155336 4.903090 5.075547 5.113943 5.075547 5.110590 5.000000 4.106837 5.143015 5.380211 4.883661 5.175222 5.088136 5.148448
[136] 4.939519 5.107210 5.120574 5.145818 5.141136 5.039414 5.174641 5.203848 5.086360 5.041393 5.146128 5.238046 4.977724 4.970203 5.060320
[151] 4.973128 5.133539 5.135133 5.118926 5.084576 5.096910 5.139564 5.198657 5.204798 5.212188 5.515874 5.431364 4.929419 5.361728 4.919078
[166] 5.110590 5.107210 5.269513 5.488593 4.928908 5.431364 5.372912 5.167317 5.389786 5.313867 5.298635 5.271842 5.505150 5.141450 5.190332
[181] 5.201397 5.281033 5.302114 5.176091 5.208844 5.103804 5.502427 5.434569 5.380211 5.351989 5.157608 5.155336 5.365488 5.328380 4.928908
[196] 5.000000 5.158362 4.806180 5.097604 5.029384 4.954243 5.146128 5.053078 4.903090 5.159868 5.107210 4.767156 5.103804 5.000000 5.227887
[211] 5.332438 5.425697 5.307785 5.267172 5.210853 5.460898 5.098644 5.041393 4.835056 5.011892 4.700167 5.390935 5.278754 5.303196 5.230449
[226] 5.342423 5.254744 5.240549 5.430559 5.332236 5.578066 5.239299 5.143015 5.221414 5.077368 4.929419 4.877947 4.945715 5.113943 5.198382
[241] 5.175802 5.454845 5.363612 5.095169 5.195900 5.537819 5.277609 5.431364 5.576917 5.226600 5.444045 5.379306 5.249198 5.267172 5.281033
[256] 5.250420 5.267172 5.220108 5.250420 5.240549 5.238046 5.256477 5.273001 5.700563 5.571126 5.414973 5.267172 5.257679 4.916454 5.332438
[271] 5.187521 5.396199 5.273001 5.195900 5.181844 5.381837 5.342423 5.371068 5.328380 5.198657 5.217484 5.133539 5.080987 5.095169 4.986772
[286] 5.113943 5.096910 5.049218 4.986772 5.071882 5.077368 5.157608 5.164353 5.171726 5.089905 5.167317 5.171726 5.108903 5.000000 5.172603
[301] 5.528274 5.664642 5.685742 5.744293 5.408749 5.403623 5.525045 5.606381 5.605155 5.655090 5.785330 5.765619 5.471292 5.407391 5.525045
[316] 5.439175 5.477121 5.510545 5.447158 5.453318 5.430559 5.367673 5.586868 5.462398 5.408070 5.328380 5.292256 5.327359 5.361728 5.741939
[331] 5.582631 5.505150 5.395326 5.238046 5.264818 5.240549 5.284431 5.255273 5.204663 5.275311 5.230449 5.277609 5.265054 5.291147 5.283301
[346] 5.250420 5.372912 5.387390 5.222716 5.278754 5.193125 5.389166 5.257679 5.330414 5.225309 5.527630 5.605305 5.514548 5.526339 5.498311
[361] 5.414973 5.420863 5.604226 5.394452 5.439333 5.410777 5.389166 5.403121 5.402567 5.322219 5.318689 5.397940 5.569231 5.491362 5.401401
[376] 5.463893 5.419956 5.267172 5.370143 5.320146 5.201397 5.181844 5.156852 5.285557 5.307496 5.266937 5.201397 5.152288 5.184691 5.350719
[391] 5.342423 5.409933 5.276462 5.161368 5.264818 5.209515 4.913814 4.880814 5.041393 5.130334 5.149219 5.086360 5.110590 5.118595 4.795066
[406] 5.089905 5.439333 5.371068 5.448320 5.346353 5.236789 5.255273 5.193125 5.236789 5.503450 5.256477 5.187521 5.301030 5.209515 5.409764
[421] 5.212188 5.053078 5.361728 5.113943 5.155336 5.070038 5.226600 5.236789 5.208173 5.150756 5.071882 5.105510 5.146128 5.249504 5.222716
[436] 5.184691 5.161667 5.187521 5.249198 5.198657 5.095169 5.241795 5.041393 5.243038 5.222716 5.146128 5.167317 5.093422 5.201397 5.408240
[451] 5.286681 5.041393 5.020775 5.176091 5.194514 5.245513 5.174641 5.190332 5.184691 5.158362 5.130334 5.117271 5.089905 5.100371 5.060698
[466] 5.217221 5.053078 5.162863 5.012415 4.977724 5.183270 5.113609 4.999565 5.130334 5.173186 5.056905 5.194514 4.770852 5.025306 4.894870
[481] 5.278754 5.187521 5.156852 5.130334 5.184691 5.054996 5.123852 5.108903 4.954243 5.139879 5.107210 5.143015 5.139879 5.125481 5.130334
[496] 5.160619 5.161368 5.103804 5.039414 5.060698 5.041393 4.822822 5.113943 5.176091 5.031408 4.975662 5.095169 5.130334 5.012837 4.968483
[511] 5.112270 4.968483 4.653213 4.578639 4.960471 5.053078 4.942008 5.041393 5.025306 5.424847 5.075547 4.767156 5.155336 4.929419 5.096562
[526] 5.165838 4.542825 5.349278 5.173186 5.136721 5.082785 5.130012 5.068186 5.150756 5.123852 4.778151 5.176091 5.102091 5.331427 5.224015
[541] 5.190332 5.190332 5.255031 5.017033 4.795880 5.173186 5.012837 5.089905 5.064458 4.948168 5.252853 5.252853 5.203848 4.785330 5.243038
[556] 5.143015 5.236789 5.054996 5.130012 5.217484 4.805501 5.130334 5.278754 5.188647 5.144574 5.033424 5.209515 5.194514 5.500511 5.434409
[571] 5.380030 5.379306 5.117271 5.075416 5.170212 5.075028 5.075028 5.155193 5.171214 5.430559 5.430559 5.472756 5.470547 5.380030 5.326336
[586] 5.378398 5.342423 5.301030 5.345962 5.368287 5.267172 5.181844 5.155336 5.364551 5.326336 5.161368 5.296446 5.283301 5.356026 5.361728
[601] 5.272074 5.307496 5.093422 5.146128 5.130012 5.135133 5.156852 5.125481 5.089905 5.126781 5.123852 5.397940 5.406114 5.373831 5.495544
[616] 5.297761 5.324282 5.342423 5.446382 5.322219 5.281033 5.250420 5.158362 5.146128 5.467164 5.278754 5.278754 5.239299 5.222716 5.297761
[631] 5.202761 5.096910 5.505150 5.162863 5.071882 4.929419 5.079181 4.991226 4.999565 4.913814 5.078819 5.014940 5.041393 5.086360 5.068186
[646] 5.204120 5.202581 5.144574 5.021189 5.130334 5.168792 5.138145 5.190332 5.369216 5.249198 5.204120 5.190332 5.190051 5.311754 5.160769
[661] 5.285557 5.198657 5.200029 5.350248 5.060698 5.082785 5.093422 5.318063 5.498311 5.346353 5.167317 5.089905 4.892095 4.929419 4.875061
[676] 5.361728 5.399674 5.379643 5.380211 5.332438 5.194376 5.238046 5.181844 5.138303 5.574031 5.612784 5.500374 5.303196 5.243038 5.329398
[691] 5.342423 5.230449 5.144574 5.209515 5.217484 4.959041 5.113943 4.934498 5.204120 4.903090 5.120245 5.218798 5.049218 5.173186 5.155336
[706] 5.113943 5.292256 5.238046 5.246745 5.375664 5.315760 5.217484 5.291147 5.250176 5.456366 5.394277 5.255273 5.262451 5.274158 5.288920
[721] 5.267172 5.275311 5.587711 5.060698 5.523746 5.123852 5.332438 5.355068 5.244277 5.259833 5.342423 5.434569 5.243038 5.267172 5.255273
[736] 5.311754 5.195900 5.485721 5.123852 5.178977 5.048830 5.089905 5.046300 5.257679 5.014521 5.002166 5.048248 5.146128 5.155336 5.041393
[751] 5.596176 5.629410 5.571012 5.620656 5.583199 5.591065 5.662758 5.578639 5.397940 5.788875 5.453318 5.453318 5.624540 5.568202 5.527449
[766] 5.565014 5.424882 5.569335 5.341435 5.187521 5.315970 5.281033 5.203835 5.273434 5.252853 5.285557 5.278754 5.245513 5.274158 5.328380
[781] 5.337060 5.270679 5.355547 5.352183 5.269279 5.454082 5.498311 5.397940 5.544068 5.544068 5.532754 5.458638 5.432969 5.479287 5.371304
[796] 5.365488 5.421821 5.389166 5.357325 5.409933 5.474071 5.327767 5.398946 5.260071 5.355452 5.397940 5.397940 5.408240 5.362384 5.317018
[811] 5.149219 5.274158 5.284431 5.201397 5.238046 5.230449 5.286681 5.276462 5.279895 5.243038 5.253338 5.271842 5.187239 5.107210 5.158362
[826] 5.130334 5.060698 5.078877 5.283301 5.146128 5.462398 5.571126 5.292256 5.250420 5.217484 5.164353 5.253822 5.454845 5.462398 5.484300
[841] 5.517064 5.204120 5.301030 5.537819 5.390051 5.337459 5.210853 5.176091 5.462398 5.311754 5.240549 5.262451 5.176091 5.161368 5.147676
[856] 5.380211 5.149219 5.167317 5.130334 5.154120 5.130334 5.230449 5.267172 5.245513 4.991226 5.037458 5.132740 5.190332 5.242790 5.255031
[871] 5.146128 5.162863 5.152288 5.149219 5.184691 4.860338 4.716003 5.071882 4.939519 5.150756 5.075547 5.150756 5.218798 5.212188 5.145973
[886] 5.240549 5.356026 5.130334 5.093422 5.146128 5.135133 5.267172 5.212188 5.222196 5.220108 5.133539 5.064458 5.138303 5.113943 5.143015
[901] 5.041393 5.000000 5.164353 4.953760 5.056905 4.939020 5.143015 5.026329 5.232996 5.269513 5.195900 5.170262 5.383815 4.973128 5.103804
[916] 5.201397 5.100026 5.190332 5.139879 5.051153 5.023252 5.105510 5.113943 5.225051 5.155336 4.863323 5.197281 5.088490 5.045323 5.408240
[931] 4.806180 5.301030 5.079181 5.190332 4.977724 5.060698 5.167317 4.667453 5.051153 5.033021 5.469822 5.144574 5.187239 5.056905 5.113943
[946] 5.111934 5.206826 5.212188 5.086360 5.067815 4.740363 5.264818 5.041393 5.118926 4.986772 5.062582 5.139879 5.184691 5.039414 5.093422
[961] 5.028978 5.217221 5.075547 5.195900 5.021189 5.060698 4.897627 4.910091 5.176091 5.091667 5.113609 5.107210 4.835691 5.103804 5.264818
[976] 5.210853 5.161368 5.113943 5.105510 5.149219 5.079181 5.105510 5.103804 5.093422 5.127105 5.170262 5.112270 5.197281 5.040998 5.161368
[991] 5.113943 5.184691 5.079181 5.037263 4.980190 4.903090 5.161068 5.217484 5.146128 5.033424
[ reached getOption("max.print") -- omitted 1051 entries ]
library(xgboost)
train.x # train data without "PID" and "Sale_Price"
train.y # log transformed "Sale_Price"
[1] 5.332438 5.235528 5.387390 5.278525 5.282169 5.373831 5.276462 5.267172 5.256237 5.234264 5.730782 5.214844 5.322219 5.278754 5.334454
[16] 5.173186 5.175802 5.152288 5.100371 5.060698 5.264818 4.982271 5.105510 5.175802 5.079181 5.164353 5.485721 5.439333 5.413300 5.330414
[31] 5.786508 5.350248 5.698970 5.505150 5.311754 5.244277 5.204120 5.283301 5.265996 5.335458 5.267378 5.255273 5.347330 5.522663 5.344392
[46] 5.612784 5.345374 5.310693 5.406370 5.433770 5.257679 5.096910 5.288920 5.181844 5.232996 4.829304 5.170262 5.086360 5.123852 5.227887
[61] 5.278754 5.559308 5.454845 5.414973 5.278754 5.190332 5.178977 5.174641 5.181844 5.346353 5.247973 5.190332 5.167642 5.427999 5.190332
[76] 5.313867 5.115611 5.361728 5.339451 5.232996 5.153052 5.110421 5.201397 5.252610 5.256477 5.152670 5.295787 5.236789 5.066326 4.883661
[91] 5.107210 5.184691 5.120574 5.250420 5.278754 5.330414 5.133539 5.218798 5.161368 5.170262 5.152288 5.224015 5.035582 5.202761 5.033424
[106] 5.088136 5.075547 5.037426 5.031408 5.110590 5.209515 5.383815 5.187521 5.220108 5.129690 5.204120 5.170262 5.190332 4.984527 5.039414
[121] 5.060698 5.155336 4.903090 5.075547 5.113943 5.075547 5.110590 5.000000 4.106837 5.143015 5.380211 4.883661 5.175222 5.088136 5.148448
[136] 4.939519 5.107210 5.120574 5.145818 5.141136 5.039414 5.174641 5.203848 5.086360 5.041393 5.146128 5.238046 4.977724 4.970203 5.060320
[151] 4.973128 5.133539 5.135133 5.118926 5.084576 5.096910 5.139564 5.198657 5.204798 5.212188 5.515874 5.431364 4.929419 5.361728 4.919078
[166] 5.110590 5.107210 5.269513 5.488593 4.928908 5.431364 5.372912 5.167317 5.389786 5.313867 5.298635 5.271842 5.505150 5.141450 5.190332
[181] 5.201397 5.281033 5.302114 5.176091 5.208844 5.103804 5.502427 5.434569 5.380211 5.351989 5.157608 5.155336 5.365488 5.328380 4.928908
[196] 5.000000 5.158362 4.806180 5.097604 5.029384 4.954243 5.146128 5.053078 4.903090 5.159868 5.107210 4.767156 5.103804 5.000000 5.227887
[211] 5.332438 5.425697 5.307785 5.267172 5.210853 5.460898 5.098644 5.041393 4.835056 5.011892 4.700167 5.390935 5.278754 5.303196 5.230449
[226] 5.342423 5.254744 5.240549 5.430559 5.332236 5.578066 5.239299 5.143015 5.221414 5.077368 4.929419 4.877947 4.945715 5.113943 5.198382
[241] 5.175802 5.454845 5.363612 5.095169 5.195900 5.537819 5.277609 5.431364 5.576917 5.226600 5.444045 5.379306 5.249198 5.267172 5.281033
[256] 5.250420 5.267172 5.220108 5.250420 5.240549 5.238046 5.256477 5.273001 5.700563 5.571126 5.414973 5.267172 5.257679 4.916454 5.332438
[271] 5.187521 5.396199 5.273001 5.195900 5.181844 5.381837 5.342423 5.371068 5.328380 5.198657 5.217484 5.133539 5.080987 5.095169 4.986772
[286] 5.113943 5.096910 5.049218 4.986772 5.071882 5.077368 5.157608 5.164353 5.171726 5.089905 5.167317 5.171726 5.108903 5.000000 5.172603
[301] 5.528274 5.664642 5.685742 5.744293 5.408749 5.403623 5.525045 5.606381 5.605155 5.655090 5.785330 5.765619 5.471292 5.407391 5.525045
[316] 5.439175 5.477121 5.510545 5.447158 5.453318 5.430559 5.367673 5.586868 5.462398 5.408070 5.328380 5.292256 5.327359 5.361728 5.741939
[331] 5.582631 5.505150 5.395326 5.238046 5.264818 5.240549 5.284431 5.255273 5.204663 5.275311 5.230449 5.277609 5.265054 5.291147 5.283301
[346] 5.250420 5.372912 5.387390 5.222716 5.278754 5.193125 5.389166 5.257679 5.330414 5.225309 5.527630 5.605305 5.514548 5.526339 5.498311
[361] 5.414973 5.420863 5.604226 5.394452 5.439333 5.410777 5.389166 5.403121 5.402567 5.322219 5.318689 5.397940 5.569231 5.491362 5.401401
[376] 5.463893 5.419956 5.267172 5.370143 5.320146 5.201397 5.181844 5.156852 5.285557 5.307496 5.266937 5.201397 5.152288 5.184691 5.350719
[391] 5.342423 5.409933 5.276462 5.161368 5.264818 5.209515 4.913814 4.880814 5.041393 5.130334 5.149219 5.086360 5.110590 5.118595 4.795066
[406] 5.089905 5.439333 5.371068 5.448320 5.346353 5.236789 5.255273 5.193125 5.236789 5.503450 5.256477 5.187521 5.301030 5.209515 5.409764
[421] 5.212188 5.053078 5.361728 5.113943 5.155336 5.070038 5.226600 5.236789 5.208173 5.150756 5.071882 5.105510 5.146128 5.249504 5.222716
[436] 5.184691 5.161667 5.187521 5.249198 5.198657 5.095169 5.241795 5.041393 5.243038 5.222716 5.146128 5.167317 5.093422 5.201397 5.408240
[451] 5.286681 5.041393 5.020775 5.176091 5.194514 5.245513 5.174641 5.190332 5.184691 5.158362 5.130334 5.117271 5.089905 5.100371 5.060698
[466] 5.217221 5.053078 5.162863 5.012415 4.977724 5.183270 5.113609 4.999565 5.130334 5.173186 5.056905 5.194514 4.770852 5.025306 4.894870
[481] 5.278754 5.187521 5.156852 5.130334 5.184691 5.054996 5.123852 5.108903 4.954243 5.139879 5.107210 5.143015 5.139879 5.125481 5.130334
[496] 5.160619 5.161368 5.103804 5.039414 5.060698 5.041393 4.822822 5.113943 5.176091 5.031408 4.975662 5.095169 5.130334 5.012837 4.968483
[511] 5.112270 4.968483 4.653213 4.578639 4.960471 5.053078 4.942008 5.041393 5.025306 5.424847 5.075547 4.767156 5.155336 4.929419 5.096562
[526] 5.165838 4.542825 5.349278 5.173186 5.136721 5.082785 5.130012 5.068186 5.150756 5.123852 4.778151 5.176091 5.102091 5.331427 5.224015
[541] 5.190332 5.190332 5.255031 5.017033 4.795880 5.173186 5.012837 5.089905 5.064458 4.948168 5.252853 5.252853 5.203848 4.785330 5.243038
[556] 5.143015 5.236789 5.054996 5.130012 5.217484 4.805501 5.130334 5.278754 5.188647 5.144574 5.033424 5.209515 5.194514 5.500511 5.434409
[571] 5.380030 5.379306 5.117271 5.075416 5.170212 5.075028 5.075028 5.155193 5.171214 5.430559 5.430559 5.472756 5.470547 5.380030 5.326336
[586] 5.378398 5.342423 5.301030 5.345962 5.368287 5.267172 5.181844 5.155336 5.364551 5.326336 5.161368 5.296446 5.283301 5.356026 5.361728
[601] 5.272074 5.307496 5.093422 5.146128 5.130012 5.135133 5.156852 5.125481 5.089905 5.126781 5.123852 5.397940 5.406114 5.373831 5.495544
[616] 5.297761 5.324282 5.342423 5.446382 5.322219 5.281033 5.250420 5.158362 5.146128 5.467164 5.278754 5.278754 5.239299 5.222716 5.297761
[631] 5.202761 5.096910 5.505150 5.162863 5.071882 4.929419 5.079181 4.991226 4.999565 4.913814 5.078819 5.014940 5.041393 5.086360 5.068186
[646] 5.204120 5.202581 5.144574 5.021189 5.130334 5.168792 5.138145 5.190332 5.369216 5.249198 5.204120 5.190332 5.190051 5.311754 5.160769
[661] 5.285557 5.198657 5.200029 5.350248 5.060698 5.082785 5.093422 5.318063 5.498311 5.346353 5.167317 5.089905 4.892095 4.929419 4.875061
[676] 5.361728 5.399674 5.379643 5.380211 5.332438 5.194376 5.238046 5.181844 5.138303 5.574031 5.612784 5.500374 5.303196 5.243038 5.329398
[691] 5.342423 5.230449 5.144574 5.209515 5.217484 4.959041 5.113943 4.934498 5.204120 4.903090 5.120245 5.218798 5.049218 5.173186 5.155336
[706] 5.113943 5.292256 5.238046 5.246745 5.375664 5.315760 5.217484 5.291147 5.250176 5.456366 5.394277 5.255273 5.262451 5.274158 5.288920
[721] 5.267172 5.275311 5.587711 5.060698 5.523746 5.123852 5.332438 5.355068 5.244277 5.259833 5.342423 5.434569 5.243038 5.267172 5.255273
[736] 5.311754 5.195900 5.485721 5.123852 5.178977 5.048830 5.089905 5.046300 5.257679 5.014521 5.002166 5.048248 5.146128 5.155336 5.041393
[751] 5.596176 5.629410 5.571012 5.620656 5.583199 5.591065 5.662758 5.578639 5.397940 5.788875 5.453318 5.453318 5.624540 5.568202 5.527449
[766] 5.565014 5.424882 5.569335 5.341435 5.187521 5.315970 5.281033 5.203835 5.273434 5.252853 5.285557 5.278754 5.245513 5.274158 5.328380
[781] 5.337060 5.270679 5.355547 5.352183 5.269279 5.454082 5.498311 5.397940 5.544068 5.544068 5.532754 5.458638 5.432969 5.479287 5.371304
[796] 5.365488 5.421821 5.389166 5.357325 5.409933 5.474071 5.327767 5.398946 5.260071 5.355452 5.397940 5.397940 5.408240 5.362384 5.317018
[811] 5.149219 5.274158 5.284431 5.201397 5.238046 5.230449 5.286681 5.276462 5.279895 5.243038 5.253338 5.271842 5.187239 5.107210 5.158362
[826] 5.130334 5.060698 5.078877 5.283301 5.146128 5.462398 5.571126 5.292256 5.250420 5.217484 5.164353 5.253822 5.454845 5.462398 5.484300
[841] 5.517064 5.204120 5.301030 5.537819 5.390051 5.337459 5.210853 5.176091 5.462398 5.311754 5.240549 5.262451 5.176091 5.161368 5.147676
[856] 5.380211 5.149219 5.167317 5.130334 5.154120 5.130334 5.230449 5.267172 5.245513 4.991226 5.037458 5.132740 5.190332 5.242790 5.255031
[871] 5.146128 5.162863 5.152288 5.149219 5.184691 4.860338 4.716003 5.071882 4.939519 5.150756 5.075547 5.150756 5.218798 5.212188 5.145973
[886] 5.240549 5.356026 5.130334 5.093422 5.146128 5.135133 5.267172 5.212188 5.222196 5.220108 5.133539 5.064458 5.138303 5.113943 5.143015
[901] 5.041393 5.000000 5.164353 4.953760 5.056905 4.939020 5.143015 5.026329 5.232996 5.269513 5.195900 5.170262 5.383815 4.973128 5.103804
[916] 5.201397 5.100026 5.190332 5.139879 5.051153 5.023252 5.105510 5.113943 5.225051 5.155336 4.863323 5.197281 5.088490 5.045323 5.408240
[931] 4.806180 5.301030 5.079181 5.190332 4.977724 5.060698 5.167317 4.667453 5.051153 5.033021 5.469822 5.144574 5.187239 5.056905 5.113943
[946] 5.111934 5.206826 5.212188 5.086360 5.067815 4.740363 5.264818 5.041393 5.118926 4.986772 5.062582 5.139879 5.184691 5.039414 5.093422
[961] 5.028978 5.217221 5.075547 5.195900 5.021189 5.060698 4.897627 4.910091 5.176091 5.091667 5.113609 5.107210 4.835691 5.103804 5.264818
[976] 5.210853 5.161368 5.113943 5.105510 5.149219 5.079181 5.105510 5.103804 5.093422 5.127105 5.170262 5.112270 5.197281 5.040998 5.161368
[991] 5.113943 5.184691 5.079181 5.037263 4.980190 4.903090 5.161068 5.217484 5.146128 5.033424
[ reached getOption("max.print") -- omitted 1051 entries ]
# replace missing by zero
train.x$Garage_Yr_Blt[is.na(train.x$Garage_Yr_Blt)] = 0
categorical.vars <- colnames(train.x)[
which(sapply(train.x,
function(x) mode(x)=="character"))]
train.matrix <- train.x[, !colnames(train.x) %in% categorical.vars,
drop=FALSE]
n.train <- nrow(train.matrix)
for(var in categorical.vars){
mylevels <- sort(unique(train.x[, var]))
m <- length(mylevels)
m <- ifelse(m>2, m, 1)
tmp.train <- matrix(0, n.train, m)
col.names <- NULL
for(j in 1:m){
tmp.train[train.x[, var]==mylevels[j], j] <- 1
col.names <- c(col.names, paste(var, '_', mylevels[j], sep=''))
}
colnames(tmp.train) <- col.names
train.matrix <- cbind(train.matrix, tmp.train)
}
# Temember to set a seed so we can reproduce your results;
# the seed does not need to be related to your UIN.
set.seed(5820)
xgb.model <- xgboost(data = as.matrix(train.matrix),
label = train.y, max_depth = 6,
eta = 0.05, nrounds = 5000,
subsample = 0.5,
verbose = FALSE)
summary(xgb.model)
Length Class Mode
handle 1 xgb.Booster.handle externalptr
raw 9273816 -none- raw
niter 1 -none- numeric
evaluation_log 2 data.table list
call 16 -none- call
params 4 -none- list
callbacks 1 -none- list
feature_names 341 -none- character
nfeatures 1 -none- numeric
res = predict(xgb.model, newdata = test.matrix )
Error in xgb.DMatrix(newdata, missing = missing) :
xgb.DMatrix does not support construction from list
as.matrix(test.matrix)
Lot_Frontage Lot_Area Year_Built Year_Remod_Add Mas_Vnr_Area BsmtFin_SF_1 BsmtFin_SF_2 Bsmt_Unf_SF Total_Bsmt_SF First_Flr_SF
[1,] 64 7406 2006 2006 84 3 0 515 1199 1220
[2,] 62 7404 1920 1950 0 7 0 861 861 861
[3,] 70 7000 1962 1962 0 1 0 72 1025 1025
Second_Flr_SF Low_Qual_Fin_SF Gr_Liv_Area Bsmt_Full_Bath Bsmt_Half_Bath Full_Bath Half_Bath Bedroom_AbvGr Kitchen_AbvGr TotRms_AbvGrd
[1,] 0 0 1220 1 0 2 0 2 1 6
[2,] 0 0 861 0 0 1 0 2 1 5
[3,] 0 0 1025 1 0 1 0 3 1 6
Fireplaces Garage_Yr_Blt Garage_Cars Garage_Area Wood_Deck_SF Open_Porch_SF Enclosed_Porch Three_season_porch Screen_Porch Pool_Area
[1,] 0 2006 2 632 105 54 0 0 0 0
[2,] 0 1920 2 288 0 0 128 0 0 0
[3,] 0 0 0 0 96 80 0 0 0 0
Misc_Val Mo_Sold Year_Sold Longitude Latitude MS_SubClass_Duplex_All_Styles_and_Ages MS_SubClass_One_and_Half_Story_Finished_All_Ages
[1,] 0 7 2006 -93.69037 42.02455 0 0
[2,] 0 11 2009 -93.60883 42.03205 0 0
[3,] 0 3 2006 -93.60507 42.03456 0 0
MS_SubClass_One_and_Half_Story_PUD_All_Ages MS_SubClass_One_and_Half_Story_Unfinished_All_Ages MS_SubClass_One_Story_1945_and_Older
[1,] 0 0 0
[2,] 0 0 1
[3,] 0 0 0
MS_SubClass_One_Story_1946_and_Newer_All_Styles MS_SubClass_One_Story_PUD_1946_and_Newer
[1,] 1 0
[2,] 0 0
[3,] 0 0
MS_SubClass_One_Story_with_Finished_Attic_All_Ages MS_SubClass_PUD_Multilevel_Split_Level_Foyer MS_SubClass_Split_Foyer
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
MS_SubClass_Split_or_Multilevel MS_SubClass_Two_and_Half_Story_All_Ages MS_SubClass_Two_Family_conversion_All_Styles_and_Ages
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 1
MS_SubClass_Two_Story_1945_and_Older MS_SubClass_Two_Story_1946_and_Newer MS_SubClass_Two_Story_PUD_1946_and_Newer MS_Zoning_C_all
[1,] 0 0 0 0
[2,] 0 0 0 0
[3,] 0 0 0 0
MS_Zoning_Floating_Village_Residential MS_Zoning_I_all MS_Zoning_Residential_High_Density MS_Zoning_Residential_Low_Density
[1,] 0 0 0 1
[2,] 0 0 0 0
[3,] 0 0 0 1
MS_Zoning_Residential_Medium_Density Street_Grvl Alley_Gravel Alley_No_Alley_Access Alley_Paved Lot_Shape_Irregular
[1,] 0 0 0 1 0 0
[2,] 1 0 0 1 0 0
[3,] 0 0 0 1 0 0
Lot_Shape_Moderately_Irregular Lot_Shape_Regular Lot_Shape_Slightly_Irregular Land_Contour_Bnk Land_Contour_HLS Land_Contour_Low
[1,] 0 1 0 0 0 0
[2,] 0 1 0 0 0 0
[3,] 0 1 0 0 0 0
Land_Contour_Lvl Utilities_AllPub Lot_Config_Corner Lot_Config_CulDSac Lot_Config_FR2 Lot_Config_Inside Land_Slope_Gtl Land_Slope_Mod
[1,] 1 1 0 0 0 1 1 0
[2,] 1 1 1 0 0 0 1 0
[3,] 1 1 0 0 0 1 1 0
Land_Slope_Sev Neighborhood_Bloomington_Heights Neighborhood_Blueste Neighborhood_Briardale Neighborhood_Brookside
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
Neighborhood_Clear_Creek Neighborhood_College_Creek Neighborhood_Crawford Neighborhood_Edwards Neighborhood_Gilbert
[1,] 0 1 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
Neighborhood_Green_Hills Neighborhood_Greens Neighborhood_Iowa_DOT_and_Rail_Road Neighborhood_Landmark Neighborhood_Meadow_Village
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
Neighborhood_Mitchell Neighborhood_North_Ames Neighborhood_Northpark_Villa Neighborhood_Northridge Neighborhood_Northridge_Heights
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 1 0 0 0
Neighborhood_Northwest_Ames Neighborhood_Old_Town Neighborhood_Sawyer Neighborhood_Sawyer_West Neighborhood_Somerset
[1,] 0 0 0 0 0
[2,] 0 1 0 0 0
[3,] 0 0 0 0 0
Neighborhood_South_and_West_of_Iowa_State_University Neighborhood_Stone_Brook Neighborhood_Timberland Neighborhood_Veenker
[1,] 0 0 0 0
[2,] 0 0 0 0
[3,] 0 0 0 0
Condition_1_Artery Condition_1_Feedr Condition_1_Norm Condition_1_PosA Condition_1_PosN Condition_1_RRAe Condition_1_RRAn
[1,] 0 0 1 0 0 0 0
[2,] 0 0 1 0 0 0 0
[3,] 1 0 0 0 0 0 0
Condition_1_RRNe Condition_2_Artery Condition_2_Feedr Condition_2_Norm Condition_2_PosA Condition_2_PosN Condition_2_RRAn
[1,] 0 0 0 1 0 0 0
[2,] 0 0 0 1 0 0 0
[3,] 0 0 0 1 0 0 0
Condition_2_RRNn Bldg_Type_Duplex Bldg_Type_OneFam Bldg_Type_Twnhs Bldg_Type_TwnhsE Bldg_Type_TwoFmCon House_Style_One_and_Half_Fin
[1,] 0 0 1 0 0 0 0
[2,] 0 0 1 0 0 0 0
[3,] 0 0 0 0 0 1 0
House_Style_One_and_Half_Unf House_Style_One_Story House_Style_SFoyer House_Style_SLvl House_Style_Two_and_Half_Fin
[1,] 0 1 0 0 0
[2,] 0 1 0 0 0
[3,] 0 0 1 0 0
House_Style_Two_and_Half_Unf House_Style_Two_Story Overall_Qual_Above_Average Overall_Qual_Average Overall_Qual_Below_Average
[1,] 0 0 0 0 0
[2,] 0 0 0 0 1
[3,] 0 0 0 1 0
Overall_Qual_Excellent Overall_Qual_Fair Overall_Qual_Good Overall_Qual_Poor Overall_Qual_Very_Excellent Overall_Qual_Very_Good
[1,] 0 0 1 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
Overall_Qual_Very_Poor Overall_Cond_Above_Average Overall_Cond_Average Overall_Cond_Below_Average Overall_Cond_Excellent
[1,] 0 0 1 0 0
[2,] 0 1 0 0 0
[3,] 0 0 1 0 0
Overall_Cond_Fair Overall_Cond_Good Overall_Cond_Poor Overall_Cond_Very_Good Overall_Cond_Very_Poor Roof_Style_Flat Roof_Style_Gable
[1,] 0 0 0 0 0 0 1
[2,] 0 0 0 0 0 0 1
[3,] 0 0 0 0 0 0 1
Roof_Style_Gambrel Roof_Style_Hip Roof_Style_Mansard Roof_Style_Shed Roof_Matl_CompShg Roof_Matl_Tar&Grv Roof_Matl_WdShake
[1,] 0 0 0 0 1 0 0
[2,] 0 0 0 0 1 0 0
[3,] 0 0 0 0 1 0 0
Roof_Matl_WdShngl Exterior_1st_AsbShng Exterior_1st_AsphShn Exterior_1st_BrkComm Exterior_1st_BrkFace Exterior_1st_CBlock
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
Exterior_1st_CemntBd Exterior_1st_HdBoard Exterior_1st_MetalSd Exterior_1st_Plywood Exterior_1st_PreCast Exterior_1st_Stone
[1,] 0 0 0 0 0 0
[2,] 0 0 1 0 0 0
[3,] 0 0 1 0 0 0
Exterior_1st_Stucco Exterior_1st_VinylSd Exterior_1st_Wd Sdng Exterior_1st_WdShing Exterior_2nd_AsbShng Exterior_2nd_AsphShn
[1,] 0 1 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
Exterior_2nd_Brk Cmn Exterior_2nd_BrkFace Exterior_2nd_CBlock Exterior_2nd_CmentBd Exterior_2nd_HdBoard Exterior_2nd_ImStucc
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
Exterior_2nd_MetalSd Exterior_2nd_Plywood Exterior_2nd_PreCast Exterior_2nd_Stone Exterior_2nd_Stucco Exterior_2nd_VinylSd
[1,] 0 0 0 0 0 1
[2,] 1 0 0 0 0 0
[3,] 1 0 0 0 0 0
Exterior_2nd_Wd Sdng Exterior_2nd_Wd Shng Mas_Vnr_Type_BrkCmn Mas_Vnr_Type_BrkFace Mas_Vnr_Type_CBlock Mas_Vnr_Type_None
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 1
[3,] 0 0 0 0 0 1
Mas_Vnr_Type_Stone Exter_Qual_Excellent Exter_Qual_Fair Exter_Qual_Good Exter_Qual_Typical Exter_Cond_Excellent Exter_Cond_Fair
[1,] 1 0 0 1 0 0 0
[2,] 0 0 0 0 1 0 0
[3,] 0 0 0 0 1 0 0
Exter_Cond_Good Exter_Cond_Poor Exter_Cond_Typical Foundation_BrkTil Foundation_CBlock Foundation_PConc Foundation_Slab
[1,] 0 0 1 0 0 1 0
[2,] 0 0 1 1 0 0 0
[3,] 0 0 1 0 1 0 0
Foundation_Stone Foundation_Wood Bsmt_Qual_Excellent Bsmt_Qual_Fair Bsmt_Qual_Good Bsmt_Qual_No_Basement Bsmt_Qual_Poor
[1,] 0 0 0 0 1 0 0
[2,] 0 0 0 1 0 0 0
[3,] 0 0 0 0 0 0 0
Bsmt_Qual_Typical Bsmt_Cond_Excellent Bsmt_Cond_Fair Bsmt_Cond_Good Bsmt_Cond_No_Basement Bsmt_Cond_Poor Bsmt_Cond_Typical
[1,] 0 0 0 0 0 0 1
[2,] 0 0 0 0 0 0 1
[3,] 1 0 0 0 0 0 1
Bsmt_Exposure_Av Bsmt_Exposure_Gd Bsmt_Exposure_Mn Bsmt_Exposure_No Bsmt_Exposure_No_Basement BsmtFin_Type_1_ALQ BsmtFin_Type_1_BLQ
[1,] 1 0 0 0 0 0 0
[2,] 0 0 0 1 0 0 0
[3,] 1 0 0 0 0 1 0
BsmtFin_Type_1_GLQ BsmtFin_Type_1_LwQ BsmtFin_Type_1_No_Basement BsmtFin_Type_1_Rec BsmtFin_Type_1_Unf BsmtFin_Type_2_ALQ
[1,] 1 0 0 0 0 0
[2,] 0 0 0 0 1 0
[3,] 0 0 0 0 0 0
BsmtFin_Type_2_BLQ BsmtFin_Type_2_GLQ BsmtFin_Type_2_LwQ BsmtFin_Type_2_No_Basement BsmtFin_Type_2_Rec BsmtFin_Type_2_Unf Heating_GasA
[1,] 0 0 0 0 0 1 1
[2,] 0 0 0 0 0 1 1
[3,] 0 0 0 0 0 1 1
Heating_GasW Heating_OthW Heating_Wall Heating_QC_Excellent Heating_QC_Fair Heating_QC_Good Heating_QC_Typical Central_Air_N
[1,] 0 0 0 1 0 0 0 0
[2,] 0 0 0 0 0 0 1 0
[3,] 0 0 0 0 0 0 1 0
Electrical_FuseA Electrical_FuseF Electrical_FuseP Electrical_SBrkr Kitchen_Qual_Excellent Kitchen_Qual_Fair Kitchen_Qual_Good
[1,] 0 0 0 1 0 0 1
[2,] 0 0 0 1 0 0 0
[3,] 0 0 0 1 0 0 0
Kitchen_Qual_Poor Kitchen_Qual_Typical Functional_Maj1 Functional_Maj2 Functional_Min1 Functional_Min2 Functional_Mod Functional_Typ
[1,] 0 0 0 0 0 0 0 1
[2,] 0 1 0 0 0 0 0 1
[3,] 0 1 0 0 0 0 0 1
Fireplace_Qu_Excellent Fireplace_Qu_Fair Fireplace_Qu_Good Fireplace_Qu_No_Fireplace Fireplace_Qu_Poor Fireplace_Qu_Typical
[1,] 0 0 0 1 0 0
[2,] 0 0 0 1 0 0
[3,] 0 0 0 1 0 0
Garage_Type_Attchd Garage_Type_Basment Garage_Type_BuiltIn Garage_Type_CarPort Garage_Type_Detchd Garage_Type_More_Than_Two_Types
[1,] 1 0 0 0 0 0
[2,] 0 0 0 0 1 0
[3,] 0 0 0 0 0 0
Garage_Type_No_Garage Garage_Finish_Fin Garage_Finish_No_Garage Garage_Finish_RFn Garage_Finish_Unf Garage_Qual_Excellent
[1,] 0 0 0 1 0 0
[2,] 0 0 0 0 1 0
[3,] 1 0 1 0 0 0
Garage_Qual_Fair Garage_Qual_Good Garage_Qual_No_Garage Garage_Qual_Poor Garage_Qual_Typical Garage_Cond_Excellent Garage_Cond_Fair
[1,] 0 0 0 0 1 0 0
[2,] 0 0 0 0 1 0 0
[3,] 0 0 1 0 0 0 0
Garage_Cond_Good Garage_Cond_No_Garage Garage_Cond_Poor Garage_Cond_Typical Paved_Drive_Dirt_Gravel Paved_Drive_Partial_Pavement
[1,] 0 0 0 1 0 0
[2,] 0 0 0 1 1 0
[3,] 0 1 0 0 0 0
Paved_Drive_Paved Pool_QC_Excellent Pool_QC_Fair Pool_QC_Good Pool_QC_No_Pool Fence_Good_Privacy Fence_Good_Wood Fence_Minimum_Privacy
[1,] 1 0 0 0 1 0 0 0
[2,] 0 0 0 0 1 0 0 0
[3,] 1 0 0 0 1 0 0 0
Fence_Minimum_Wood_Wire Fence_No_Fence Misc_Feature_Elev Misc_Feature_Gar2 Misc_Feature_None Misc_Feature_Othr Misc_Feature_Shed
[1,] 0 1 0 0 1 0 0
[2,] 0 1 0 0 1 0 0
[3,] 0 1 0 0 1 0 0
Misc_Feature_TenC Sale_Type_COD Sale_Type_Con Sale_Type_ConLD Sale_Type_ConLI Sale_Type_ConLw Sale_Type_CWD Sale_Type_New Sale_Type_Oth
[1,] 0 0 0 0 0 0 0 1 0
[2,] 0 0 0 0 0 0 0 0 1
[3,] 0 0 0 0 0 0 0 0 0
Sale_Type_VWD Sale_Type_WD Sale_Condition_Abnorml Sale_Condition_AdjLand Sale_Condition_Alloca Sale_Condition_Family
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 1 0 0 0 0
Sale_Condition_Normal Sale_Condition_Partial
[1,] 0 1
[2,] 1 0
[3,] 1 0
[ reached getOption("max.print") -- omitted 876 rows ]